import request from '@/utils/request'

const api_name = '/admin/product'

export default {
  cancelSale(skuId) {
    return request.get(`${api_name}/cancelSale/${skuId}`)
  },

  onSale(skuId) {
    return request.get(`${api_name}/onSale/${skuId}`)
  },
  remove(skuId) {
    return request.delete(`${api_name}/deleteSku/${skuId}`)
  },

  getListBySpuId(spuId) {
    return request.get(`${api_name}/findBySpuId/${spuId}`)
  },

  get(skuId) {
    return request.get(`${api_name}/getSkuById/${skuId}`)
  },

  getList(page, limit) {
    return request.get(`${api_name}/list/${page}/${limit}`)
  },

  addUpdate(skuInfo) {
    return request.post(
      `${api_name}/${skuInfo.id ? 'update' : 'save'}SkuInfo`,
      skuInfo
    )
  },

  getSpuImageList(spuId) {
    return request.get(`${api_name}/spuImageList/${spuId}`)
  },

  getSpuSaleAttrList(spuId) {
    return request.get(`${api_name}/spuSaleAttrList/${spuId}`)
  }
}
